#
faces = [{'faceId': '078c1a0e-974d-4410-b997-f0f70d42ac4d',
  'faceRectangle': {'top': 115, 'left': 381, 'width': 76, 'height': 76},
  'faceAttributes': {'smile': 0.0,
   'gender': 'male',
   'age': 24.0,
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.0,
    'neutral': 1.0,
    'sadness': 0.0,
    'surprise': 0.0},
   'hair': {'bald': 0.05,
    'invisible': False,
    'hairColor': [{'color': 'brown', 'confidence': 0.98},
     {'color': 'black', 'confidence': 0.89},
     {'color': 'blond', 'confidence': 0.44},
     {'color': 'red', 'confidence': 0.17},
     {'color': 'other', 'confidence': 0.12},
     {'color': 'gray', 'confidence': 0.11},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '1bda813e-2458-47b5-a139-74745d4d2f34',
  'faceRectangle': {'top': 92, 'left': 623, 'width': 75, 'height': 75},
  'faceAttributes': {'smile': 0.001,
   'gender': 'male',
   'age': 24.0,
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.001,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.001,
    'neutral': 0.998,
    'sadness': 0.0,
    'surprise': 0.0},
   'hair': {'bald': 0.18,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 1.0},
     {'color': 'brown', 'confidence': 0.94},
     {'color': 'other', 'confidence': 0.26},
     {'color': 'gray', 'confidence': 0.19},
     {'color': 'red', 'confidence': 0.04},
     {'color': 'blond', 'confidence': 0.04},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '1dd596c0-4b1e-4487-9c1e-355b135d5ba5',
  'faceRectangle': {'top': 157, 'left': 132, 'width': 65, 'height': 65},
  'faceAttributes': {'smile': 0.621,
   'gender': 'female',
   'age': 25.0,
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.001,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.621,
    'neutral': 0.378,
    'sadness': 0.0,
    'surprise': 0.0},
   'hair': {'bald': 0.06,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 0.89},
     {'color': 'other', 'confidence': 0.88},
     {'color': 'red', 'confidence': 0.52},
     {'color': 'gray', 'confidence': 0.32},
     {'color': 'brown', 'confidence': 0.28},
     {'color': 'blond', 'confidence': 0.08},
     {'color': 'white', 'confidence': 0.0}]}}}
 ]

# 创建字典
glasses = {}
smile = {}
hairColor = {}
age = {}
gender = {}

# 将人脸信息加入字典
count = 0
while count < len(faces):
    glasses["Person{}".format(count + 1)] = faces[count]['faceAttributes']['glasses']
    smile["Person{}".format(count + 1)] = faces[count]['faceAttributes']['smile']
    hairColor["Person{}".format(count + 1)] = faces[count]['faceAttributes']['hair']['hairColor'][0]['color']
    age["Person{}".format(count + 1)] = faces[count]['faceAttributes']['age']
    gender["Person{}".format(count + 1)] = faces[count]['faceAttributes']['gender']
    count += 1

# 打印
print("眼镜：", glasses)
print("微笑指数：", smile)
print("头发颜色：", hairColor)
print("年龄：", age)
print("性别：", gender)


# 运行结果
# 眼镜： {'Person1': 'NoGlasses', 'Person2': 'NoGlasses', 'Person3': 'NoGlasses'}
# 微笑指数： {'Person1': 0.0, 'Person2': 0.001, 'Person3': 0.621}
# 头发颜色： {'Person1': 'brown', 'Person2': 'black', 'Person3': 'black'}
# 年龄： {'Person1': 24.0, 'Person2': 24.0, 'Person3': 25.0}
# 性别： {'Person1': 'male', 'Person2': 'male', 'Person3': 'female'}

